package com.owbtgad.common.utils;

import android.content.Context;
import android.view.Gravity;
import android.widget.Toast;

import androidx.annotation.StringRes;

import com.coder.zzq.smartshow.toast.SmartToast;


/**
 * Toast工具
 */
public class ToastUtils {

    public static void showToast(Context context, @StringRes int strId) {
        try {
            SmartToast.showLongAtLocation(strId, Gravity.BOTTOM, 0, DisplayUtil.dp2px(context, 30));
        } catch (Exception e) {
            e.printStackTrace();
            try {
                Toast.makeText(context,strId,Toast.LENGTH_LONG).show();
            }catch (Exception e1){
                e1.printStackTrace();
            }
        }
    }

    public static void showToast(Context context, String text) {
        try {
            SmartToast.showLongAtLocation(text, Gravity.BOTTOM, 0, DisplayUtil.dp2px(context, 30));
        } catch (Exception e) {
            e.printStackTrace();
            try {
                Toast.makeText(context,text,Toast.LENGTH_LONG).show();
            }catch (Exception e1){
                e1.printStackTrace();
            }
        }
    }

}
